<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>诊断</title>
    <link rel="stylesheet" href="../../../layui/css/layui.css">

</head>
<body style="background-color:#fff;">
<div class="layui-fluid">
    <fieldset class="layui-elem-field site-demo-button layui-col-md-offset2 layui-col-md8"
              style="margin-top: 30px;padding:15px;">
        <legend>诊断信息</legend>
        <form class="layui-form layui-form-pane" lay-filter="add_triage" action="">
            <div class="layui-form-item">
                <label class="layui-form-label">患者编号</label>
                <div class="layui-input-block">
                    <!-- 隐藏文本域 用于存放 id -->
                    <input type="hidden" name="id">
                    <input type="text" name="patientId" disabled class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">患者姓名</label>
                <div class="layui-input-block">
                    <input type="text" name="patientName" disabled class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">科室编号</label>
                <div class="layui-input-block">
                    <input type="text" name="departmentId" disabled class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">科室</label>
                <div class="layui-input-block">
                    <input type="text" name="departmentName" disabled class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">医生编号</label>
                <div class="layui-input-block">
                    <input type="text" name="userId" disabled class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">医生姓名</label>
                <div class="layui-input-block">
                    <input type="text" name="username" disabled class="layui-input">
                </div>
            </div>


            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">症状描述</label>
                <div class="layui-input-block">
                    <textarea placeholder="请填写症状描述" class="layui-textarea"
                              name="illnessInfo"></textarea>
                </div>
            </div>
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">症状意见</label>
                <div class="layui-input-block">
                    <textarea placeholder="请填写症状意见" class="layui-textarea"
                              name="advice"></textarea>
                </div>
            </div>
            <div class="layui-form-item" style="text-align: center">
                <button class="layui-btn" lay-submit="" lay-filter="add_triage_btn">完成</button>
            </div>
        </form>
    </fieldset>
</div>


<script src="../../../layui/layui.js"></script>
<script>
    layui.use(['jquery', 'form', 'layedit'], function () {
        var $ = layui.jquery; // 注册 jquery 组件
        var form = layui.form;// 注册 form 组件
        var layedit = layui.layedit;// 注册 layedit 组件

        // 当前地址
        var url = window.location.href;
        // 获取分诊记录 id
        var id = url.substring(url.lastIndexOf('=') + 1);


        //根据 id 使用 ajax 获取数据

        //模拟数据
        var triage = {
            "id": "101",
            "patientId": "101",
            "patientName": "山里娃234",
            "departmentId": "101",
            "departmentName": "内科",
            "userId": "101",
            "username": "山里娃233",
            "illnessInfo": "发烧，咳嗽",
            "advice": "多喝热水",
        };
        //表单回显数据
        form.val('add_triage', {
            "id": triage.id,
            "patientId": triage.patientId,
            "patientName": triage.patientName,
            "departmentId": triage.departmentId,
            "departmentName": triage.departmentName,
            "userId": triage.userId,
            "username": triage.username,
            "illnessInfo": triage.illnessInfo,
            "advice": triage.advice,
        });
        //表单提交
        form.on('submit(add_triage_btn)', function (data) {
            console.log(data.elem); //被执行事件的元素DOM对象，一般为button对象
            console.log(data.form); //被执行提交的form对象，一般在存在form标签时才会返回
            console.log(data.field); //当前容器的全部表单字段，名值对形式：{name: value}
            return false;
        });
    });
</script>
</body>
</html>
